from opcua import Client
import pandas as pd
from common.config import opcUaConfig as Config
from opcUaSrc.plc.tools import *
import time


def saveData1(commonNodes):
    data1 = getData1(commonNodes)
    df = pd.read_csv(Config.data1File)
    df = pd.concat([pd.DataFrame(data1), df], ignore_index=True)
    df = df.head(Config.data1Num)
    df.to_csv(Config.data1File, index=False)

def saveDatam(commonNodes,root):
    # 以时间命名文件名
    fileName = time.strftime("%Y.%m.%d.%H.%M.%S", time.localtime(time.time())) + '-' + time.strftime("%Y.%m.%d.%H.%M.%S",time.localtime()) + '-' + str(Config.serverID) + '.csv'
    getDatam(commonNodes).to_csv(root+ '/' + fileName, index=False)
    print(f"--------------生成 {root} csv...............")
